﻿@model KPIS.GERP.Models.ICM.Bid

@{
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    ViewBag.Title = "ประกาศ [BI]";
    ViewBag.Descr = "ประกาศ";

    var modelPrItem = new KPIS.GERP.WEB.GIMS.PurchaseRequestItemService.PurchaseRequestItemServiceClient()
        .Select(new PurchaseRequestItem() { PrId = Model.PrId, RecordStatus = "!" + RecordStatus.DeletedStatus }, null).FirstOrDefault();
    var modelPprItem = new KPIS.GERP.WEB.GIMS.PrePurchaseRequestItemService.PrePurchaseRequestItemServiceClient()
    .Select(new PrePurchaseRequestItem() { PrItemId = modelPrItem.PrItemId }, null).FirstOrDefault();
}

<div class="block-button-menu-above">
    @*@Html.ActionLink("กลับไปหน้าแสดงข้อมูลทั้งหมด", "Index", new { PrId = Model.PrId }, new { @class = "btn btn-gray button-standard-width btn-small", role="button" })*@

    @if (ViewBag.bEditable ||
         Model != null && Model.RecordStatus == RecordStatus.ReturnedStatus)
    {
        if (ViewBag.NoLayout != true)
        {@Html.ButtonEdit(new { Id = Model.BidId })}

        if (Model != null && (Model.RecordStatus == RecordStatus.WaitStatus || Model.RecordStatus == RecordStatus.ReturnedStatus))
        {
            <button type="button" id="edit" onclick="window.location.href ='@Url.Action("Edit", new {id=Model.BidId, prid=Model.PrId, showApproveButton = ViewBag.ShowApproveButton})'"
                    class="btn button-standard-width btn-small btn-info"
                    data-rel="tooltip" role="button">
                <i class="icon-plus bigger-120"></i>&nbsp;&nbsp;แก้ไข
            </button>
            if (ViewBag.ShowApproveButton)
            {
                <button type="button" id="submitBidInParentFrame"
                        class="btn button-standard-width btn-small btn-yellow"
                        data-rel="tooltip" role="button">
                    <i class="icon-plus bigger-120"></i>&nbsp;&nbsp;ส่งขออนุมัติประกาศ
                </button>
            }
        }
    }

    <button type="button" class="btn btn-gray button-standard-width btn-small" onclick="window.location.href ='@Url.Action("Report", new { BidId = Model.BidId })'" role="button">
        รายงานขอซื้อขอจ้าง
    </button>
    <button type="button" onclick="window.location.href ='@Url.Action("BidderReport", new { id= Model.BidId })'"
            class="btn button-standard-width btn-small btn-blue"
            data-rel="tooltip" role="button">
        <i class="icon-file bigger-120"></i>&nbsp;&nbsp;รายงานผู้ผ่านการคัดเลือก
    </button>
    <button type="button" onclick="window.location.href ='@Url.Action("PriceReport", new { id= Model.BidId })'"
            class="btn button-standard-width btn-small btn-blue"
            data-rel="tooltip" role="button">
        <i class="icon-file bigger-120"></i>&nbsp;&nbsp;รายงานผลการสอบราคา
    </button>
    <button type="button" onclick="window.location.href ='@Url.Action("OfferReport", new { id= Model.BidId, PprId=modelPprItem.PprId })'"
            class="btn button-standard-width btn-small btn-blue"
            data-rel="tooltip" role="button">
        <i class="icon-file bigger-120"></i>&nbsp;&nbsp;รายงานผลการรับซอง
    </button>

</div> 

@Html.Partial("_DetailsForm")

@if (Request["Related"] == "1")
{
    @*<hr/> 
    <h4 class="header bigger lighter blue" style="margin-bottom: 0px;">
        ข้อมูลขอซื้อ/จ้าง @Model.PurchaseRequest.Code - @Model.PurchaseRequest.Name
        &nbsp;&nbsp;
        <a href="/Bid/Details/1003?" target="_blank">
            (เปิดในหน้าต่างใหม่ <i class="icon-external-link"></i>)
        </a>
    </h4>
    @Html.Partial("~/Views/Purchase/_DetailsForm.cshtml", Model.PurchaseRequest)*@
    var url = "../../Purchase/Details?Id=" + Model.PrId +
              "&EmptyLayout=" + (ViewBag.EmptyLayout == true ? "true" : "false") +
              "&output=embed";
    <div class="widget-box">
        <div class="widget-header header-color-blue2">
            <div class="widget-toolbar">
                <a href="#" data-action="collapse" style="color: #fff; font-size: large;">
                    <i class="icon-chevron-up"></i>
                    ข้อมูลพัสดุ/บริการที่ซื้อ/จ้าง
                </a>
            </div>
        </div>
        <div class="widget-body">
            <div class="widget-main">
                <iframe id="iframe17" src="@url" frameborder="0" style="width: 100%; height: 500px" target='_top'></iframe>
            </div>
        </div>
    </div>
}

@section scripts
{
    <script>
        $("#submitBidInParentFrame").on("click", function (e) {
            try {
                $('#form_approve', window.parent.document).submit();
            } catch (Exception) {
                alert(Exception);
            }
        });
    </script>
}